app.controller('confirmsign', function ($scope, $rootScope, $http, $interval, $compile, $state) {
    $scope.one = function () {
        $state.go(one.stateName);
    }

    $scope.jumpTo = function (type) {
        $scope.customerEmail = $(".customer-email").val();
        if($scope.customerEmail){
            localStorage.setItem("sdm-customer-email",$scope.customerEmail);
        }

        countersign.params.type = type;
        $state.go(countersign.stateName);
    }

    //获得数据
    $scope.confrim = function () {
        if(!$scope.feSignUrl){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "工程师签名为空"));
            return;
        }
        if(!$scope.customerSignUrl){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "客户签名为空"));
            return;
        }
        var ids = JSON.parse(localStorage.getItem("sdmSignCaseIdAry"));

        if(!ids || ids.length==0){
            return;
        }
        /*if(!$scope.customerEmail){
            $rootScope.tipPopups.show(($rootScope.tipMessage = "客户邮箱地址为空"));
            return;
        }*/

        $scope.customerEmail = $(".customer-email").val();

        ///提交签名
        var postData = {
            "ids": ids,
            "feSignUrl": $scope.feSignUrl,
            "customerSignUrl": $scope.customerSignUrl,
            "customerEmail":$scope.customerEmail
        };
        postHttp($http, 'installtionCase/commitSign', postData, function (res) {
            if (res.code === 0 && res.msg == "success") {
                localStorage.removeItem("sdm-caseId");
                localStorage.removeItem("sdm-customer-email");
                $scope.one();
                $scope.$applyAsync();
            } else {
                $rootScope.tipPopups.show(($rootScope.tipMessage = res.msg));
            }
        });
    }
    //初始化
    function init(){
        $scope.feSignUrl = localStorage.getItem("sdm-countfeSignUrl");
        $scope.customerSignUrl = localStorage.getItem("sdm-countcustomerSignUrl");
        var ce =  localStorage.getItem("sdm-customer-email");
        if(ce){
            $(".customer-email").val(ce);
        }
        $scope.$applyAsync();
    }
    init();

    $(document).ready(function(){
        var innnerheight = window.innerHeight;
        var height=(innnerheight - 250 )+'px';
        document.getElementById("content").style.height = height;
    })

    reloadJs();

});